﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LotteryVote.Logic.Web;
using LotteryVote.Logic;
using LotteryVote.Entity;
using LotteryVote.Utility;

namespace LotteryVote.Controls
{
    public partial class MemberCommissionInfo : MemberControl
    {
        CommisionGroupFacade commGroupFacade = new CommisionGroupFacade();
        public CommissionGroupModel MemberGroupModel { get; private set; }
        public IList<EnumDescriptionAttribute> CompanyTypeList { get; private set; }
        public IList<EnumDescriptionAttribute> GameTypeList { get; private set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            CompanyTypeList = EnumHelper.GetDescription<CompanyType>();
            GameTypeList = EnumHelper.GetDescription<GameTypeEnum>();
            MemberGroupModel = commGroupFacade.GetCommissionGropModelByMember(CurrentUser, LotterySpeciesEnum.VietnamLottery);
        }

        public ConcreteCommission FindComm(int companyTypeId, int gameTypeId)
        {
            return MemberGroupModel.ConcreteCommissionList.Where(it =>
                it.CompanyType.Id == companyTypeId && it.GameType.GameId == gameTypeId).FirstOrDefault() ?? new ConcreteCommission();
        }
    }
}